import os
import yaml
"""利用yaml保存中间值"""
def read_yaml(key): # 读取yaml中的数据
    with open(os.getcwd() + "/extract.yaml", encoding="utf-8") as f:
        value = yaml.load(stream=f, Loader=yaml.FullLoader)
        return value[key]

def write_yaml(data): # 往yaml中写数据
    with open(os.getcwd() + "/extract.yaml", encoding="utf-8", mode="a") as f:
        yaml.dump(data, stream=f, allow_unicode=True)

def clear_yaml(): # 清除yaml中的数据
    with open(os.getcwd() + "/extract.yaml", encoding="utf-8", mode="a") as f:
        f.truncate()